package com.njtoyo.taxi.admin.mapper.master.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;

import java.util.Arrays;
import java.util.Objects;

public enum CouponUsageCondition {
    full(0, "FULL"),  //满减
    max(1, "MAX");//折扣
    @EnumValue
    private final int code;
    private final String desc;

    CouponUsageCondition(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public static CouponUsageCondition getByCode(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        return Arrays.stream(CouponUsageCondition.values()).filter(e -> e.getCode() == code).findFirst().get();
    }
}
